package com.qfedu.yanglao20admin.visit.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.yanglao20.common.CommonResult;
import com.qfedu.yanglao20.common.annotation.LogInfo;
import com.qfedu.yanglao20admin.visit.param.ReturnVisitParam;
import com.qfedu.yanglao20admin.visit.param.VisitFlagParam;
import com.qfedu.yanglao20admin.visit.service.ReturnVisitService;
import com.qfedu.yanglao20admin.visit.vo.RecordVO;
import com.qfedu.yanglao20admin.visit.vo.ReturnVisitVO;
import com.qfedu.yanglao20admin.visit.vo.VisitVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yujie
 * @data 2023/5/4 20:16
 */
@Api(tags = "服务回访")
@RestController
@RequestMapping("/visit")
public class ReturnVisitController {

    @Resource
    private ReturnVisitService returnVisitService;

    @LogInfo
    @ApiOperation(value = "分页服务回访信息", notes = "分页服务回访信息")
    @GetMapping("/page")
    public CommonResult<ReturnVisitVO> page(ReturnVisitParam param) {
        Page<ReturnVisitVO> returnVisitVOPage = returnVisitService.pageReturnVisit(param);
        return CommonResult.success(returnVisitVOPage);
    }

    @LogInfo
    @ApiOperation(value = "填写回访满意度", notes = "填写回访满意度")
    @PostMapping("/update")
    public CommonResult<VisitFlagParam> updateReturnVisit(VisitFlagParam param) {
        returnVisitService.updateVisit(param);
        return CommonResult.success();
    }

    @LogInfo
    @ApiOperation(value = "根据id查询回访记录", notes = "根据id查询回访记录")
    @GetMapping("/query")
    public CommonResult<RecordVO> queryReturnVisit(@RequestParam @ApiParam("服务回访id") Integer id) {
        RecordVO recordVO = returnVisitService.selectRecordById(id);
        return CommonResult.success(recordVO);
    }

    @LogInfo
    @ApiOperation(value = "展示回访率满意度", notes = "展示回访率满意度")
    @GetMapping("/rate")
    public CommonResult<VisitVO> queryCount() {
        VisitVO visitVO = returnVisitService.selectCount();
        return CommonResult.success(visitVO);
    }
}
